$(function () {
    var baseUrl = window.location.protocol + "//" + window.location.host;

    layui.use(['layer','jquery','laydate'], function () {
        var $=layui.jquery;
        //标语
        $('#slogan').on('change',function () {
            var postData={
                slogan: $(this).val(),
            };

            $.ajax({
                type: "POST",
                url: baseUrl+"/api/user/addSlogan",
                data: postData,
                dataType: "json",
                success: function(data){
                    if(data.code==1){
                        $('#slogan').val(data.data.slogan);
                    }else{
                        layer.msg(data.msg, {icon: 5,time: 2000});
                        return false;
                    }
                }
            });
        });

        //执行一个laydate实例
        var laydate = layui.laydate;
        laydate.render({
            elem: '#selectTime', //指定元素
            change: function(value, date){ //监听日期被切换
                lay('#testView').html(value);
            },
            done: function(value, date, endDate){
                location.href="/timeline/0/"+value;
            }
        });

        laydate.render({
            elem: '#startTime', //指定元素
            range: true,
            change: function(value, date){ //监听日期被切换
                lay('#testView').html(value);
            },
            done: function(value, date, endDate){
                location.href="/timeline/"+value;
            }
        });


    });

});